﻿Presage Android Library Documentation
=================================

Code :

Name : Generations

Package: com.generations

Api Key: 267854


Installation Instructions
-------------------------

Presage Library Requirements:

-   JDK 1.6 or later

-   Android 2.2 or later

####  

### Step 1: Adding Presage

Current version is `1.7.2` published the `2015-08-31`.

Download the lib here : https://s3-eu-west-1.amazonaws.com/ogury-sdk/production/1.7.2-manual/presage-lib-1.7.2-manual.jar

1.  Download `presage-lib.jar`

2.  Copy it on your `libs` folder or add it in your classpath


### Step 2 - Editing Your Manifest File

Copy these lines in your AndroidManifest.xml inside <application> tag.
Don't forget your API Key: 267854

```
<!-- PRESAGE LIBRARY -->
<meta-data android:name="presage_key" android:value="267840"/>
<service android:name="io.presage.services.PresageServiceImp"/>
<activity android:name="io.presage.activities.PresageActivity"
  android:label="@string/app_name"
  android:theme="@style/Presage.Theme.Transparent"
  android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
  android:hardwareAccelerated="true" >
    <intent-filter>
      <action android:name="io.presage.intent.action.LAUNCH_WEBVIEW" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
<receiver android:name="io.presage.receivers.BootReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.DATE_CHANGED"/>
        <action android:name="io.presage.receivers.BootReceiver.RESTART_SERVICE"/>
    </intent-filter>
</receiver>

```
Placed just before the opening <application> tag:

Default internet and boot permissions

```
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
```

Tracking permissions

```
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
<uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" />
```

Shortcut permissions

```
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
```

### Step3 - Adding styles

If you have `styles.xml` inside `res/values` folder, copy there lines inside:

```
<style name="Presage.Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>
```

Else, create `styles.xml` inside `res/values` folder with there lines inside:

```
<resources>
  <style name="Presage.Theme.Transparent" parent="android:Theme">
      <item name="android:windowIsTranslucent">true</item>
      <item name="android:windowBackground">@android:color/transparent</item>
      <item name="android:windowContentOverlay">@null</item>
      <item name="android:windowNoTitle">true</item>
      <item name="android:backgroundDimEnabled">false</item>
  </style>
</resources>
```

### Step 4 - Editing Your Main File


Add the following import

```
import io.presage.Presage;
```

Inside your activity in onCreate, please add:

```
Presage.getInstance().setContext(this.getBaseContext());
Presage.getInstance().start();
```

### Step 5 Enabling Interstitial

Import the following

```
import io.presage.utils.IADHandler;
```

Ad these lines in your activity:

```
@Override
protected void onResume() {
  super.onResume();

  Presage.getInstance().adToServe("interstitial", new IADHandler() {

    @Override
    public void onAdNotFound() {
      Log.i("PRESAGE", "ad not found");
    }

    @Override
    public void onAdFound() {
      Log.i("PRESAGE", "ad found");
    }

    @Override
    public void onAdClosed() {
      Log.i("PRESAGE", "ad closed");
    }
  });
}
```
 

### Step 6 - Build your Application

And Enjoy!

## Pro Tips

### Proguard configuration

Here is the configuration to add to your proguard configuration file:

```
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }

-keep class shared_presage.** { *; }
-keep class io.presage.** { *; }
-keepclassmembers class io.presage.** {
 *;
}

-keepattributes *Annotation*
-keepattributes JavascriptInterface
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}
```
